package com.zsrt.devbase.common.utils;

import java.io.UnsupportedEncodingException;

public class ChangePassword {

	/**
	 * 密码加密
	 * 加密的密钥 
	 *@Value("${zsrt.eshop.key}")
	 *private String accountKey;
	 * 
	 * @param id	用户生成的uuid
	 * @param beforePasswd	用户输入的密码
	 * @return	加密过后的密码
	 */
	public static String changePasswd(String id,String beforePasswd,String accountKey){
		byte[] keyByte;
		String password = null;
		try {
			keyByte = DESedeUtil.getKeyByte(accountKey);
			String ivSpec = id.substring(0, 8);
			password=DESedeUtil.encryptMode(keyByte, beforePasswd, ivSpec);
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return password;
	}
}
